<?php

    class Destinations_model extends MY_Model
    {
        function __construct()
        {
            parent::__construct();
            $this->table = 'destinations';
        }

        function get_all_parents($destination_id=NULL)
        {
            $q = "SELECT * FROM destinations WHERE parent_ID = 0";
            if(isset($destination_id)) $q .= " AND ID != $destination_id";

            $res = $this->db->query($q)->result_array();
            return $res;
        }

        function get_children($parent_id)
        {
            $q = "SELECT * FROM destinations WHERE parent_ID = $parent_id";

            $res = $this->db->query($q)->result_array();
            return $res;
        }

    }

?>
